import React, { Component } from "react";

import Child1 from "./Child1";
import Child2 from "./Child2";

class App extends Component {
  state = {
    count: 0,
  };

  fn = (c) => {
    // console.log("fn", c);
    this.setState({
      count: c,
    });
  };

  render() {
    return (
      <>
        <h2>状态提升 - {this.state.count}</h2>
        {/* 子传父：在父组件的子组件标签上面传入自定义事件 */}
        <Child1 onGetCount={this.fn} />
        <Child2 count={this.state.count} />
      </>
    );
  }
}

export default App;
